package com.peng.leetcode.str;

/**
 * StrStr
 *
 * @author: lupeng6
 * @create: 2023/2/19 17:32
 */
public class StrStr {
    public int strStr(String haystack, String needle) {
        int len1 = haystack.length();
        int len2 = needle.length();
        for (int i = 0; i < len1; i++) {
            boolean flag = true;
            for (int j = 0; j < len2; j++) {
                if ((i + j) >= len1 || haystack.charAt(i + j) != needle.charAt(j)) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                return i;
            }
        }
        return -1;
    }
}
